package com.larly.manager.upload;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.model.PutObjectResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.File;

@Component
public class CosManager {

    @Resource
    private COSClient cosClient;

    @Value("${cos.client.bucketName}")
    private String bucketName;

    /**
     * 上传文件
     */
    public PutObjectResult putObject(String bucketName, String key, File file) {
        return cosClient.putObject(bucketName, key, file);
    }

    public PutObjectResult putObject(String key, File file) {
        return putObject(bucketName, key, file);
    }

}
